Public Class frmChitProperties
    Inherits System.Windows.Forms.Form

    Const OBJECTIVE_RULEINDEX As Integer = 9
    ' form sizing
    Const FORM_OBJECTIVEWIDTH As Integer = 526
    Const FORM_OBJECTIVEHEIGHT As Integer = 392
    Const FORM_UNITWIDTH As Integer = 272
    Const FORM_UNITHEIGHT As Integer = 504
    Const FORM_TOKENHEIGHT As Integer = 464
    Const FORM_TOKENWIDTH As Integer = 266

    Const CLOSE_TOKENLEFT As Integer = 176
    Const CLOSE_TOKENTOP As Integer = 400
    Const CLOSE_UNITTOP As Integer = 336
    Const CLOSE_OBJECTIVELEFT As Integer = 432
    Const CLOSE_OBJECTIVETOP As Integer = 328

    Const DEFAULT_LOS As Integer = 5
    Const DEFAULT_LOSPOWER As Integer = 100
    Const DEFAULT_SIZE As Integer = 100
    Const DEFAULT_ZOC As Integer = 2
    Const DEFAULT_MOVEMENTSPEED As Integer = 8

    Private ptrItem As cmplib01.GroundChitType  ' this is the new item
    Private ptrCGD As cmplib01.CampaignerGameData  ' provided so we can show the rules and resources 
    Private mMode As OpenMode = OpenMode.ObjectiveType
    Private objectiveItemIndex = OBJECTIVE_RULEINDEX
    Private moveTypes() As String

    Private sizeValues() As Integer = {5, 10, 25, 50, 100, 200, 400, 600, 1000, 15000}
    Friend WithEvents lblMovementRate As System.Windows.Forms.Label
    Friend WithEvents btnC1 As System.Windows.Forms.Button

    Private mvarMapUnitName As String
    Friend WithEvents pnlCommon As System.Windows.Forms.Panel
    Friend WithEvents Panel8 As System.Windows.Forms.Panel
    Friend WithEvents cboLOSPower As System.Windows.Forms.ComboBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents pnlIndicators As System.Windows.Forms.Panel
    Friend WithEvents btnAddIndicator As System.Windows.Forms.Button
    Friend WithEvents btnRemoveIndicator As System.Windows.Forms.Button
    Friend WithEvents lstIndicators As System.Windows.Forms.ListBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Panel6 As System.Windows.Forms.Panel
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents numReinforcementRange As System.Windows.Forms.NumericUpDown
    Friend WithEvents Panel5 As System.Windows.Forms.Panel
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents numSuggestedPV As System.Windows.Forms.NumericUpDown
    Friend WithEvents Panel4 As System.Windows.Forms.Panel
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents numZOCRange As System.Windows.Forms.NumericUpDown
    Friend WithEvents Panel3 As System.Windows.Forms.Panel
    Friend WithEvents cboSize As System.Windows.Forms.ComboBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    Friend WithEvents numLOSRange As System.Windows.Forms.NumericUpDown
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents pnlItem As System.Windows.Forms.Panel
    Friend WithEvents pnlProperty As System.Windows.Forms.Panel
    Friend WithEvents txtTypeName As System.Windows.Forms.TextBox
    Friend WithEvents pnlTitleItem As System.Windows.Forms.Panel
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents lblIcons As System.Windows.Forms.Label
    Friend WithEvents picOwner As System.Windows.Forms.PictureBox
    Friend WithEvents txtDescription As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Private mvarCancelled As Boolean = True
    Friend WithEvents lstAttributes As System.Windows.Forms.ListBox
    Friend WithEvents btnAddAttribute As System.Windows.Forms.Button
    Friend WithEvents btnRemoveAttribute As System.Windows.Forms.Button
    Friend WithEvents lblAttrs As System.Windows.Forms.Label '// in case they hit the X to close the form

    Private cMenu As New ContextMenu


    Public Enum OpenMode
        ObjectiveType = 1
        UnitType = 2
        TokenType = 3
    End Enum

    Private Enum ItemListIndex
        Description = 0
        [Name] = 1
        TypeName = 2
        LOS = 3
        LOSPower = 4
        Size = 5
        UsesZOC = 6
        ZOCRange = 7
        Icons = 8
        ObjectiveRules = 9       ' objective type only
        MovementClass = 9     ' token and unit only
        MoveSpeed = 10          ' token and unit only
        TokenRule = 11            ' token only
    End Enum

    Public Sub New(ByVal openM As OpenMode, ByRef CGD As cmplib01.CampaignerGameData, ByRef Item As cmplib01.GroundChitType, ByVal MovementTypes() As String, ByVal mapUnitName As String, Optional ByVal edit As Boolean = False)
        InitializeComponent()

        ' if its an edit, the cancel button doesn't appear.
        If edit = True Then
            '// its an edit, only one button shows
            btnC2.Text = "Close"
            btnC1.Visible = False
        Else
            btnC2.Text = "Cancel"
            btnC1.Text = "Add"
            btnC1.Visible = True
            'btnCancel.Location = New Point(btnClose.Location.X - btnCancel.Width - 6, btnClose.Location.Y)
        End If

        ' we need the movementtypes (infantry, wheeled, etc) for movement class information
        moveTypes = MovementTypes

        ' set the pointer to the locally used variable and the mode, then populate
        ptrCGD = CGD
        ptrItem = Item
        mMode = openM

        CreateIndicatorMenu()

        'lblLOSMiles.Text = mapUnitName
        'lblZOCmiles.Text = mapUnitName

        '// if the turn is 1 day or greater, we need to show Per Day.
        If ptrCGD.TurnLength >= cmplib01.TurnLength_cgd.FullDay Then
            lblMovementRate.Text = "Per Day"
        Else
            lblMovementRate.Text = "Per Hour"
        End If

        Populate()

    End Sub

    Public Property actionCancelled() As Boolean
        Get
            Return mvarCancelled
        End Get
        Set(ByVal value As Boolean)
            mvarCancelled = value
        End Set
    End Property

#Region "Populate Info"
    Public Sub Populate()

        objectiveItemIndex = OBJECTIVE_RULEINDEX    ' reset the index so the correct spot is modified

        PopulateComboBoxes()

        ' base properties, common to all ground chits
        PopulateBaseProperties()

        ' add the type-specific properties here.
        Select Case mMode
            Case OpenMode.ObjectiveType : PopulateObjectiveType()
            Case OpenMode.UnitType : PopulateUnitType()
            Case OpenMode.TokenType : PopulateTokenType()
        End Select

    End Sub

    Public Sub PopulateBaseProperties()
        Try
            Dim comGround As cmplib01.GroundChitType
            comGround = CType(ptrItem, cmplib01.GroundChitType)

            ' show the basic data, common to all chits
            txtTypeName.Text = comGround.TypeName
            numLOSRange.Value = comGround.LOS

            cboLOSPower.Text = LOSPowerText(comGround.LOSPower)

            cboSize.Text = SizeText(ptrItem.Size)

            numZOCRange.Value = comGround.ZOCRange

            txtDescription.Text = comGround.Description

            ListIndicators()
            ListAttributes()

            If comGround.UsesZOC = True Then
                'cboUsesZOC.Text = "Yes"
            Else
                'cboUsesZOC.Text = "No"
            End If

            picOwner.Image = comGround.Icon(cmplib01.IconImageIndex_cgd.Owner)
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub ListAttributes()
        Try
            Dim attr As Collection = ptrItem.ChitAttributes
            lstAttributes.Items.Clear()

            For Each str As String In attr
                lstAttributes.Items.Add(str)
            Next

        Catch ex As Exception
            HandleException(c_Module, ex)

        End Try
    End Sub

    Private Sub PopulateComboBoxes()
        Try
            With cboSize.Items
                .Add("Tiny")
                .Add("Very Small")
                .Add("Slight")
                .Add("Small")
                .Add("Average")
                .Add("Big")
                .Add("Large")
                .Add("Immense")
                .Add("Huge")
                .Add("Massive")
                .Add("Titanic")
            End With

            With cboLOSPower.Items
                .Add("Weak")
                .Add("Low")
                .Add("Average")
                .Add("Good")
                .Add("Strong")
                .Add("Powerful")
                .Add("Very Powerful")
            End With

        Catch ex As Exception

        End Try
    End Sub

    Private Function SizeText(ByVal size As Single) As String
        Select Case size
            Case Is <= 5 : Return "Tiny"
            Case Is <= 10 : Return "Very Small"
            Case Is <= 25 : Return "Slight"
            Case Is <= 50 : Return "Small"
            Case Is <= 100 : Return "Average"
            Case Is <= 200 : Return "Big"
            Case Is <= 400 : Return "Large"
            Case Is <= 600 : Return "Immense"
            Case Is <= 1000 : Return "Huge"
            Case Is <= 1500 : Return "Massive"
            Case Is <= 10000 : Return "Titanic"
        End Select
    End Function

    Private Function SizeValue(ByVal size As String) As Single
        Select Case size
            Case "Tiny" : Return 5
            Case "Very Small" : Return 10
            Case "Slight" : Return 25
            Case "Small" : Return 50
            Case "Average" : Return 100
            Case "Big" : Return 200
            Case "Large" : Return 400
            Case "Immense" : Return 600
            Case "Huge" : Return 1000
            Case "Massive" : Return 1500
            Case "Titanic" : Return 10000
            Case Else : Return "Average"
        End Select
    End Function

    Private Function LOSPowerText(ByVal power As Single) As String
        Select Case power
            Case Is >= 150 : Return "Weak"
            Case Is >= 120 : Return "Low"
            Case Is >= 100 : Return "Average"
            Case Is >= 80 : Return "Good"
            Case Is >= 60 : Return "Strong"
            Case Is >= 50 : Return "Powerful"
            Case Is >= 30 : Return "Very Powerful"
            Case Else
                Return "Average"
        End Select
    End Function

    Private Function LOSPowerValue(ByVal power As String) As Single
        Select Case power
            Case "Weak" : Return 150
            Case "Low" : Return 120
            Case "Average" : Return 100
            Case "Good" : Return 80
            Case "Strong" : Return 60
            Case "Powerful" : Return 50
            Case "Very Powerful" : Return 30
            Case Else
                Return 1
        End Select
    End Function

    Public Sub PopulateObjectiveType()
        ' add any rules that the objective exposes, followed by a "New Rule" entry
        Dim rul As cmplib01.RuleType
        Dim key As String
        Dim objective As cmplib01.ObjectiveType
        Dim i As Int16

        ' for local use
        objective = ptrItem

        Dim de As DictionaryEntry

        'Me.lbSugPV.Visible = False
        Me.numSuggestedPV.Enabled = False
        'Me.lblReinforcementRange.Visible = False
        Me.numReinforcementRange.Enabled = False

        ' populate the rules
        For Each rul In objective.GCRules
            lstChitRules.Items.Add(rul)
        Next

        ' populate the resources this objective type generates
        Dim res As cmplib01.Resource

        For Each de In objective.ObjectiveResources.HT
            key = de.Key
            res = objective.ObjectiveResources.Item(key)
            lstObjectiveResources.Items.Add(res)
        Next

        ' size the form properly and hide unneccesary crap
        pnlUnitProperties.Visible = False
        pnlRulesResources.Visible = True
        pnlTokenProperties.Visible = False
        Me.Width = FORM_OBJECTIVEWIDTH
        Me.Height = FORM_OBJECTIVEHEIGHT

        ' set the panel size
        pnlRulesResources.Height = 312

        btnAddResource.Visible = True
        btnRemoveResource.Visible = True

        btnC2.Left = 432
        btnC2.Top = 328
        btnC1.Left = btnC2.Left - btnC1.Width - 5
        btnC1.Top = btnC2.Top

    End Sub

    Public Sub PopulateUnitType()
        Dim mType As String
        Dim unit As cmplib01.UnitType
        Dim rul As cmplib01.RuleType

        Try
            Me.Width = FORM_OBJECTIVEWIDTH
            Me.Height = FORM_OBJECTIVEHEIGHT
            pnlTokenProperties.Visible = False
            pnlRulesResources.Visible = True
            pnlRulesResources.Height = 152

            'Me.lbSugPV.Visible = True
            Me.numSuggestedPV.Enabled = True
            'Me.lblReinforcementRange.Visible = True
            Me.numReinforcementRange.Enabled = True

            btnAddResource.Visible = False
            btnRemoveResource.Visible = False

            unit = ptrItem
            btnC2.Top = 328
            btnC2.Left = 432
            btnC1.Left = btnC2.Left - btnC1.Width - 5
            btnC1.Top = btnC2.Top

            btnC2.Visible = True

            If unit.MovementClassID = -1 Then
                unit.MovementClassID = 0
            End If

            '// movement rate
            'cboMovementRate.SelectedIndex = unit.MovementRate
            '// easy peasy

            numSuggestedPV.Value = unit.SuggestedPointValue
            numReinforcementRange.Value = unit.ReinforcementRange

            mType = moveTypes(unit.MovementClassID)

            ' populate the unit's rules
            For Each rul In unit.GCRules
                lstChitRules.Items.Add(rul)
            Next

            ' populate the combo box for movement types
            Dim i As Int16

            For i = 0 To UBound(moveTypes)
                cboMovementType.Items.Add(moveTypes(i).ToString)
            Next

            cboMovementType.SelectedIndex = unit.MovementClassID
            'dtvMovementSpeed.TotalValue = unit.MovementSpeed
            numMovementSpeed.Value = unit.MovementSpeed

            chkCanBeTransported.Checked = unit.CanBeTransported
            chkCanTransport.Checked = unit.CanTransport
            numTransportCost.Value = unit.TransportCost
            numTransportCapacity.Value = unit.TransportCapacity

            '// show or hide the extra data
            updateTransportVisibilty()

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try

    End Sub

    Public Sub PopulateTokenType()
        ' it gets its info from UnitTypes, plus adds its own rule
        PopulateUnitType()

        Dim tok As cmplib01.TokenType

        Me.Height = FORM_TOKENHEIGHT
        Me.Width = FORM_TOKENWIDTH
        btnC2.Top = CLOSE_TOKENTOP
        btnC2.Left = CLOSE_TOKENLEFT
        btnC1.Top = btnC2.Top
        btnC1.Left = btnC2.Left - btnC1.Width - 6

        pnlTokenProperties.Visible = True

        'tok = ptrItem

    End Sub

#End Region

#Region "Add/Remove Rules"
    Private Sub btnAddRule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRule.Click
        'Dim newRule As New cmplib01.Rule()
        'Dim fSelect As New frmRulePicker(ptrCGD, newRule)
        'Dim objectiveType As cmplib01.ObjectiveType

        'Try
        '    ' catches if there are no rules created yet
        '    If Not fSelect.CancelPressed Then fSelect.ShowDialog()

        '    If Not fSelect.CancelPressed Then
        '        ' add the rule to the provided chit (unit OR objective... how fucking cool is that?)

        '        ptrItem.GCRules.Add(newRule)

        '        ' add the rule to the listbox... like... duh.
        '        lstChitRules.Items.Add(newRule)
        '        'Debug.WriteLine(newRule.Key & " added")
        '    End If
        'Catch ex As Exception
        '    HandleException(c_Module, ex)
        'End Try

        Try
            Dim fSelect As New frmAssignRules(ptrItem, ptrCGD)
            fSelect.ShowDialog()
            listExitingRules()

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try

    End Sub

    Private Sub listExitingRules()
        Try
            lstChitRules.Items.Clear()
            For Each rult As cmplib01.RuleType In ptrItem.GCRules
                lstChitRules.Items.Add(rult)
            Next

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub btnRemoveRule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveRule.Click
        If Not lstChitRules.SelectedItem Is Nothing Then
            Dim sKey As String = lstChitRules.SelectedItem.key

            Try
                ptrItem.GCRules.Remove(lstChitRules.SelectedItem)
                lstChitRules.Items.Remove(lstChitRules.SelectedItem)

            Catch ex As Exception
                Debug.WriteLine("!! Error in btnRemoveRule_Click, " & ex.Message.ToString)
            End Try

        End If
    End Sub
#End Region

#Region "Add/Remove Resources"
    Private Sub btnAddResource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddResource.Click
        Dim newResource As New cmplib01.Resource()
        Dim fSelect As New frmResourcePicker(ptrCGD, newResource)
        Dim objectiveType As cmplib01.ObjectiveType

        ' catches if there are no resources created yet
        If Not fSelect.CancelPressed Then fSelect.ShowDialog()

        If Not fSelect.CancelPressed Then
            Dim sKey As String
            sKey = newResource.Key
            ' add the resource to the objective's collection. Tokens have a rule added in a different box!
            objectiveType = ptrItem
            objectiveType.ObjectiveResources.Add(newResource, sKey)
            ' add to the listbox
            lstObjectiveResources.Items.Add(objectiveType.ObjectiveResources.Item(sKey))
        End If

    End Sub

    Private Sub btnRemoveResource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveResource.Click
        If Not lstObjectiveResources.SelectedItem Is Nothing Then
            Dim sKey As String = lstObjectiveResources.SelectedItem.key
            Dim ptrObj As cmplib01.ObjectiveType = ptrItem
            Try
                lstObjectiveResources.Items.Remove(ptrObj.ObjectiveResources.Item(sKey))
                ptrObj.ObjectiveResources.HT.Remove(sKey)
            Catch
                Debug.WriteLine(ptrObj.ObjectiveResources.Count)
            End Try
        End If
    End Sub
#End Region


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lstObjectiveResources As System.Windows.Forms.ListBox
    Friend WithEvents lblRules As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents btnAddResource As System.Windows.Forms.Button
    Friend WithEvents btnRemoveResource As System.Windows.Forms.Button
    Friend WithEvents btnAddRule As System.Windows.Forms.Button
    Friend WithEvents btnRemoveRule As System.Windows.Forms.Button
    Friend WithEvents btnC2 As System.Windows.Forms.Button
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents cboMovementType As System.Windows.Forms.ComboBox
    Friend WithEvents pnlUnitProperties As System.Windows.Forms.Panel
    Friend WithEvents pnlTokenProperties As System.Windows.Forms.Panel
    Friend WithEvents txtTokenRule As System.Windows.Forms.TextBox
    Friend WithEvents btnNewTokenRule As System.Windows.Forms.Button
    Friend WithEvents lstChitRules As System.Windows.Forms.ListBox
    Friend WithEvents pnlRulesResources As System.Windows.Forms.Panel
    Friend WithEvents numMovementSpeed As System.Windows.Forms.NumericUpDown
    Friend WithEvents numTransportCost As System.Windows.Forms.NumericUpDown
    Friend WithEvents chkCanBeTransported As System.Windows.Forms.CheckBox
    Friend WithEvents chkCanTransport As System.Windows.Forms.CheckBox
    Friend WithEvents numTransportCapacity As System.Windows.Forms.NumericUpDown
    Friend WithEvents lbltransportcapacity As System.Windows.Forms.Label
    Friend WithEvents lbltransportcost As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmChitProperties))
        Me.pnlRulesResources = New System.Windows.Forms.Panel
        Me.lstChitRules = New System.Windows.Forms.ListBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.btnAddRule = New System.Windows.Forms.Button
        Me.btnRemoveRule = New System.Windows.Forms.Button
        Me.btnAddResource = New System.Windows.Forms.Button
        Me.btnRemoveResource = New System.Windows.Forms.Button
        Me.lblRules = New System.Windows.Forms.Label
        Me.lstObjectiveResources = New System.Windows.Forms.ListBox
        Me.pnlUnitProperties = New System.Windows.Forms.Panel
        Me.lblMovementRate = New System.Windows.Forms.Label
        Me.lbltransportcapacity = New System.Windows.Forms.Label
        Me.lbltransportcost = New System.Windows.Forms.Label
        Me.chkCanBeTransported = New System.Windows.Forms.CheckBox
        Me.chkCanTransport = New System.Windows.Forms.CheckBox
        Me.numTransportCapacity = New System.Windows.Forms.NumericUpDown
        Me.numTransportCost = New System.Windows.Forms.NumericUpDown
        Me.numMovementSpeed = New System.Windows.Forms.NumericUpDown
        Me.cboMovementType = New System.Windows.Forms.ComboBox
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.pnlTokenProperties = New System.Windows.Forms.Panel
        Me.btnNewTokenRule = New System.Windows.Forms.Button
        Me.txtTokenRule = New System.Windows.Forms.TextBox
        Me.btnC2 = New System.Windows.Forms.Button
        Me.btnC1 = New System.Windows.Forms.Button
        Me.pnlCommon = New System.Windows.Forms.Panel
        Me.Panel8 = New System.Windows.Forms.Panel
        Me.cboLOSPower = New System.Windows.Forms.ComboBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.pnlIndicators = New System.Windows.Forms.Panel
        Me.btnAddIndicator = New System.Windows.Forms.Button
        Me.btnRemoveIndicator = New System.Windows.Forms.Button
        Me.lstIndicators = New System.Windows.Forms.ListBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Panel6 = New System.Windows.Forms.Panel
        Me.Label12 = New System.Windows.Forms.Label
        Me.numReinforcementRange = New System.Windows.Forms.NumericUpDown
        Me.Panel5 = New System.Windows.Forms.Panel
        Me.Label1 = New System.Windows.Forms.Label
        Me.numSuggestedPV = New System.Windows.Forms.NumericUpDown
        Me.Panel4 = New System.Windows.Forms.Panel
        Me.Label2 = New System.Windows.Forms.Label
        Me.numZOCRange = New System.Windows.Forms.NumericUpDown
        Me.Panel3 = New System.Windows.Forms.Panel
        Me.cboSize = New System.Windows.Forms.ComboBox
        Me.Label5 = New System.Windows.Forms.Label
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.numLOSRange = New System.Windows.Forms.NumericUpDown
        Me.Label6 = New System.Windows.Forms.Label
        Me.pnlItem = New System.Windows.Forms.Panel
        Me.pnlProperty = New System.Windows.Forms.Panel
        Me.txtTypeName = New System.Windows.Forms.TextBox
        Me.pnlTitleItem = New System.Windows.Forms.Panel
        Me.Label7 = New System.Windows.Forms.Label
        Me.lblIcons = New System.Windows.Forms.Label
        Me.picOwner = New System.Windows.Forms.PictureBox
        Me.txtDescription = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label13 = New System.Windows.Forms.Label
        Me.lstAttributes = New System.Windows.Forms.ListBox
        Me.btnAddAttribute = New System.Windows.Forms.Button
        Me.btnRemoveAttribute = New System.Windows.Forms.Button
        Me.lblAttrs = New System.Windows.Forms.Label
        Me.pnlRulesResources.SuspendLayout()
        Me.pnlUnitProperties.SuspendLayout()
        CType(Me.numTransportCapacity, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.numTransportCost, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.numMovementSpeed, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.pnlTokenProperties.SuspendLayout()
        Me.pnlCommon.SuspendLayout()
        Me.Panel8.SuspendLayout()
        Me.pnlIndicators.SuspendLayout()
        Me.Panel6.SuspendLayout()
        CType(Me.numReinforcementRange, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel5.SuspendLayout()
        CType(Me.numSuggestedPV, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel4.SuspendLayout()
        CType(Me.numZOCRange, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel3.SuspendLayout()
        Me.Panel2.SuspendLayout()
        CType(Me.numLOSRange, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.pnlItem.SuspendLayout()
        Me.pnlProperty.SuspendLayout()
        Me.pnlTitleItem.SuspendLayout()
        CType(Me.picOwner, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'pnlRulesResources
        '
        Me.pnlRulesResources.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlRulesResources.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlRulesResources.Controls.Add(Me.lstAttributes)
        Me.pnlRulesResources.Controls.Add(Me.btnAddAttribute)
        Me.pnlRulesResources.Controls.Add(Me.btnRemoveAttribute)
        Me.pnlRulesResources.Controls.Add(Me.lblAttrs)
        Me.pnlRulesResources.Controls.Add(Me.lstChitRules)
        Me.pnlRulesResources.Controls.Add(Me.Label9)
        Me.pnlRulesResources.Controls.Add(Me.btnAddRule)
        Me.pnlRulesResources.Controls.Add(Me.btnRemoveRule)
        Me.pnlRulesResources.Controls.Add(Me.btnAddResource)
        Me.pnlRulesResources.Controls.Add(Me.btnRemoveResource)
        Me.pnlRulesResources.Controls.Add(Me.lblRules)
        Me.pnlRulesResources.Controls.Add(Me.lstObjectiveResources)
        Me.pnlRulesResources.Location = New System.Drawing.Point(264, 8)
        Me.pnlRulesResources.Name = "pnlRulesResources"
        Me.pnlRulesResources.Size = New System.Drawing.Size(248, 150)
        Me.pnlRulesResources.TabIndex = 1
        '
        'lstChitRules
        '
        Me.lstChitRules.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstChitRules.Location = New System.Drawing.Point(8, 19)
        Me.lstChitRules.Name = "lstChitRules"
        Me.lstChitRules.Size = New System.Drawing.Size(192, 54)
        Me.lstChitRules.TabIndex = 0
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(8, 156)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(112, 16)
        Me.Label9.TabIndex = 14
        Me.Label9.Text = "Resources"
        '
        'btnAddRule
        '
        Me.btnAddRule.Image = CType(resources.GetObject("btnAddRule.Image"), System.Drawing.Image)
        Me.btnAddRule.Location = New System.Drawing.Point(208, 19)
        Me.btnAddRule.Name = "btnAddRule"
        Me.btnAddRule.Size = New System.Drawing.Size(32, 23)
        Me.btnAddRule.TabIndex = 13
        '
        'btnRemoveRule
        '
        Me.btnRemoveRule.Image = CType(resources.GetObject("btnRemoveRule.Image"), System.Drawing.Image)
        Me.btnRemoveRule.Location = New System.Drawing.Point(208, 41)
        Me.btnRemoveRule.Name = "btnRemoveRule"
        Me.btnRemoveRule.Size = New System.Drawing.Size(32, 23)
        Me.btnRemoveRule.TabIndex = 12
        '
        'btnAddResource
        '
        Me.btnAddResource.Image = CType(resources.GetObject("btnAddResource.Image"), System.Drawing.Image)
        Me.btnAddResource.Location = New System.Drawing.Point(208, 176)
        Me.btnAddResource.Name = "btnAddResource"
        Me.btnAddResource.Size = New System.Drawing.Size(32, 23)
        Me.btnAddResource.TabIndex = 11
        '
        'btnRemoveResource
        '
        Me.btnRemoveResource.Image = CType(resources.GetObject("btnRemoveResource.Image"), System.Drawing.Image)
        Me.btnRemoveResource.Location = New System.Drawing.Point(208, 208)
        Me.btnRemoveResource.Name = "btnRemoveResource"
        Me.btnRemoveResource.Size = New System.Drawing.Size(32, 23)
        Me.btnRemoveResource.TabIndex = 10
        '
        'lblRules
        '
        Me.lblRules.Location = New System.Drawing.Point(8, 5)
        Me.lblRules.Name = "lblRules"
        Me.lblRules.Size = New System.Drawing.Size(112, 16)
        Me.lblRules.TabIndex = 9
        Me.lblRules.Text = "Rules"
        '
        'lstObjectiveResources
        '
        Me.lstObjectiveResources.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstObjectiveResources.Location = New System.Drawing.Point(8, 176)
        Me.lstObjectiveResources.Name = "lstObjectiveResources"
        Me.lstObjectiveResources.Size = New System.Drawing.Size(192, 119)
        Me.lstObjectiveResources.TabIndex = 2
        '
        'pnlUnitProperties
        '
        Me.pnlUnitProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlUnitProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlUnitProperties.Controls.Add(Me.lblMovementRate)
        Me.pnlUnitProperties.Controls.Add(Me.lbltransportcapacity)
        Me.pnlUnitProperties.Controls.Add(Me.lbltransportcost)
        Me.pnlUnitProperties.Controls.Add(Me.chkCanBeTransported)
        Me.pnlUnitProperties.Controls.Add(Me.chkCanTransport)
        Me.pnlUnitProperties.Controls.Add(Me.numTransportCapacity)
        Me.pnlUnitProperties.Controls.Add(Me.numTransportCost)
        Me.pnlUnitProperties.Controls.Add(Me.numMovementSpeed)
        Me.pnlUnitProperties.Controls.Add(Me.cboMovementType)
        Me.pnlUnitProperties.Controls.Add(Me.Label10)
        Me.pnlUnitProperties.Controls.Add(Me.Label11)
        Me.pnlUnitProperties.Location = New System.Drawing.Point(264, 168)
        Me.pnlUnitProperties.Name = "pnlUnitProperties"
        Me.pnlUnitProperties.Size = New System.Drawing.Size(248, 152)
        Me.pnlUnitProperties.TabIndex = 2
        '
        'lblMovementRate
        '
        Me.lblMovementRate.AutoSize = True
        Me.lblMovementRate.Location = New System.Drawing.Point(186, 38)
        Me.lblMovementRate.Name = "lblMovementRate"
        Me.lblMovementRate.Size = New System.Drawing.Size(49, 13)
        Me.lblMovementRate.TabIndex = 37
        Me.lblMovementRate.Text = "Per Hour"
        '
        'lbltransportcapacity
        '
        Me.lbltransportcapacity.Location = New System.Drawing.Point(8, 131)
        Me.lbltransportcapacity.Name = "lbltransportcapacity"
        Me.lbltransportcapacity.Size = New System.Drawing.Size(104, 16)
        Me.lbltransportcapacity.TabIndex = 36
        Me.lbltransportcapacity.Text = "Transport Capacity"
        '
        'lbltransportcost
        '
        Me.lbltransportcost.Location = New System.Drawing.Point(8, 89)
        Me.lbltransportcost.Name = "lbltransportcost"
        Me.lbltransportcost.Size = New System.Drawing.Size(96, 16)
        Me.lbltransportcost.TabIndex = 35
        Me.lbltransportcost.Text = "Transport Cost"
        '
        'chkCanBeTransported
        '
        Me.chkCanBeTransported.Location = New System.Drawing.Point(9, 60)
        Me.chkCanBeTransported.Name = "chkCanBeTransported"
        Me.chkCanBeTransported.Size = New System.Drawing.Size(152, 24)
        Me.chkCanBeTransported.TabIndex = 34
        Me.chkCanBeTransported.Text = "Can Be Transported"
        '
        'chkCanTransport
        '
        Me.chkCanTransport.Location = New System.Drawing.Point(8, 108)
        Me.chkCanTransport.Name = "chkCanTransport"
        Me.chkCanTransport.Size = New System.Drawing.Size(104, 24)
        Me.chkCanTransport.TabIndex = 33
        Me.chkCanTransport.Text = "Can Transport"
        '
        'numTransportCapacity
        '
        Me.numTransportCapacity.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numTransportCapacity.DecimalPlaces = 1
        Me.numTransportCapacity.Location = New System.Drawing.Point(115, 128)
        Me.numTransportCapacity.Maximum = New Decimal(New Integer() {1000, 0, 0, 0})
        Me.numTransportCapacity.Name = "numTransportCapacity"
        Me.numTransportCapacity.Size = New System.Drawing.Size(65, 20)
        Me.numTransportCapacity.TabIndex = 0
        Me.numTransportCapacity.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'numTransportCost
        '
        Me.numTransportCost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numTransportCost.DecimalPlaces = 1
        Me.numTransportCost.Location = New System.Drawing.Point(115, 86)
        Me.numTransportCost.Maximum = New Decimal(New Integer() {1000, 0, 0, 0})
        Me.numTransportCost.Name = "numTransportCost"
        Me.numTransportCost.Size = New System.Drawing.Size(65, 20)
        Me.numTransportCost.TabIndex = 31
        Me.numTransportCost.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'numMovementSpeed
        '
        Me.numMovementSpeed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numMovementSpeed.DecimalPlaces = 1
        Me.numMovementSpeed.Location = New System.Drawing.Point(115, 34)
        Me.numMovementSpeed.Maximum = New Decimal(New Integer() {1000, 0, 0, 0})
        Me.numMovementSpeed.Name = "numMovementSpeed"
        Me.numMovementSpeed.Size = New System.Drawing.Size(65, 20)
        Me.numMovementSpeed.TabIndex = 24
        Me.numMovementSpeed.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        Me.numMovementSpeed.Value = New Decimal(New Integer() {1, 0, 0, 0})
        '
        'cboMovementType
        '
        Me.cboMovementType.Location = New System.Drawing.Point(115, 8)
        Me.cboMovementType.Name = "cboMovementType"
        Me.cboMovementType.Size = New System.Drawing.Size(125, 21)
        Me.cboMovementType.TabIndex = 18
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(11, 8)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(96, 16)
        Me.Label10.TabIndex = 17
        Me.Label10.Text = "Movement Type"
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(11, 36)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(96, 16)
        Me.Label11.TabIndex = 16
        Me.Label11.Text = "Movement Speed"
        '
        'pnlTokenProperties
        '
        Me.pnlTokenProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlTokenProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlTokenProperties.Controls.Add(Me.btnNewTokenRule)
        Me.pnlTokenProperties.Controls.Add(Me.txtTokenRule)
        Me.pnlTokenProperties.Location = New System.Drawing.Point(8, 328)
        Me.pnlTokenProperties.Name = "pnlTokenProperties"
        Me.pnlTokenProperties.Size = New System.Drawing.Size(248, 64)
        Me.pnlTokenProperties.TabIndex = 3
        '
        'btnNewTokenRule
        '
        Me.btnNewTokenRule.BackColor = System.Drawing.SystemColors.Control
        Me.btnNewTokenRule.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnNewTokenRule.Location = New System.Drawing.Point(16, 23)
        Me.btnNewTokenRule.Name = "btnNewTokenRule"
        Me.btnNewTokenRule.Size = New System.Drawing.Size(80, 23)
        Me.btnNewTokenRule.TabIndex = 17
        Me.btnNewTokenRule.Text = "Select Rule"
        Me.btnNewTokenRule.UseVisualStyleBackColor = False
        '
        'txtTokenRule
        '
        Me.txtTokenRule.Location = New System.Drawing.Point(114, 24)
        Me.txtTokenRule.Name = "txtTokenRule"
        Me.txtTokenRule.ReadOnly = True
        Me.txtTokenRule.Size = New System.Drawing.Size(120, 20)
        Me.txtTokenRule.TabIndex = 16
        Me.txtTokenRule.Text = "[None]"
        '
        'btnC2
        '
        Me.btnC2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnC2.Location = New System.Drawing.Point(176, 400)
        Me.btnC2.Name = "btnC2"
        Me.btnC2.Size = New System.Drawing.Size(75, 23)
        Me.btnC2.TabIndex = 2
        Me.btnC2.Text = "C2"
        '
        'btnC1
        '
        Me.btnC1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnC1.Location = New System.Drawing.Point(95, 400)
        Me.btnC1.Name = "btnC1"
        Me.btnC1.Size = New System.Drawing.Size(75, 23)
        Me.btnC1.TabIndex = 4
        Me.btnC1.Text = "C1"
        '
        'pnlCommon
        '
        Me.pnlCommon.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlCommon.Controls.Add(Me.Panel8)
        Me.pnlCommon.Controls.Add(Me.pnlIndicators)
        Me.pnlCommon.Controls.Add(Me.Panel6)
        Me.pnlCommon.Controls.Add(Me.Panel5)
        Me.pnlCommon.Controls.Add(Me.Panel4)
        Me.pnlCommon.Controls.Add(Me.Panel3)
        Me.pnlCommon.Controls.Add(Me.Panel2)
        Me.pnlCommon.Controls.Add(Me.pnlItem)
        Me.pnlCommon.Controls.Add(Me.lblIcons)
        Me.pnlCommon.Controls.Add(Me.picOwner)
        Me.pnlCommon.Controls.Add(Me.txtDescription)
        Me.pnlCommon.Controls.Add(Me.Label8)
        Me.pnlCommon.Controls.Add(Me.Label13)
        Me.pnlCommon.Location = New System.Drawing.Point(8, 8)
        Me.pnlCommon.Name = "pnlCommon"
        Me.pnlCommon.Size = New System.Drawing.Size(248, 312)
        Me.pnlCommon.TabIndex = 5
        '
        'Panel8
        '
        Me.Panel8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel8.Controls.Add(Me.cboLOSPower)
        Me.Panel8.Controls.Add(Me.Label4)
        Me.Panel8.Location = New System.Drawing.Point(3, 83)
        Me.Panel8.Name = "Panel8"
        Me.Panel8.Size = New System.Drawing.Size(240, 20)
        Me.Panel8.TabIndex = 22
        '
        'cboLOSPower
        '
        Me.cboLOSPower.FormattingEnabled = True
        Me.cboLOSPower.Location = New System.Drawing.Point(109, -1)
        Me.cboLOSPower.Name = "cboLOSPower"
        Me.cboLOSPower.Size = New System.Drawing.Size(130, 21)
        Me.cboLOSPower.TabIndex = 10
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(3, 3)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(96, 16)
        Me.Label4.TabIndex = 9
        Me.Label4.Text = "Detection Power"
        '
        'pnlIndicators
        '
        Me.pnlIndicators.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlIndicators.Controls.Add(Me.btnAddIndicator)
        Me.pnlIndicators.Controls.Add(Me.btnRemoveIndicator)
        Me.pnlIndicators.Controls.Add(Me.lstIndicators)
        Me.pnlIndicators.Controls.Add(Me.Label3)
        Me.pnlIndicators.Location = New System.Drawing.Point(3, 194)
        Me.pnlIndicators.Name = "pnlIndicators"
        Me.pnlIndicators.Size = New System.Drawing.Size(240, 55)
        Me.pnlIndicators.TabIndex = 10
        '
        'btnAddIndicator
        '
        Me.btnAddIndicator.Image = CType(resources.GetObject("btnAddIndicator.Image"), System.Drawing.Image)
        Me.btnAddIndicator.Location = New System.Drawing.Point(3, 22)
        Me.btnAddIndicator.Name = "btnAddIndicator"
        Me.btnAddIndicator.Size = New System.Drawing.Size(29, 25)
        Me.btnAddIndicator.TabIndex = 15
        '
        'btnRemoveIndicator
        '
        Me.btnRemoveIndicator.Image = CType(resources.GetObject("btnRemoveIndicator.Image"), System.Drawing.Image)
        Me.btnRemoveIndicator.Location = New System.Drawing.Point(38, 22)
        Me.btnRemoveIndicator.Name = "btnRemoveIndicator"
        Me.btnRemoveIndicator.Size = New System.Drawing.Size(29, 25)
        Me.btnRemoveIndicator.TabIndex = 14
        '
        'lstIndicators
        '
        Me.lstIndicators.FormattingEnabled = True
        Me.lstIndicators.Location = New System.Drawing.Point(70, 5)
        Me.lstIndicators.Name = "lstIndicators"
        Me.lstIndicators.Size = New System.Drawing.Size(166, 43)
        Me.lstIndicators.TabIndex = 10
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(3, 3)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(78, 16)
        Me.Label3.TabIndex = 9
        Me.Label3.Text = "Indicators"
        '
        'Panel6
        '
        Me.Panel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel6.Controls.Add(Me.Label12)
        Me.Panel6.Controls.Add(Me.numReinforcementRange)
        Me.Panel6.Location = New System.Drawing.Point(3, 159)
        Me.Panel6.Name = "Panel6"
        Me.Panel6.Size = New System.Drawing.Size(240, 20)
        Me.Panel6.TabIndex = 5
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(3, 3)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(96, 16)
        Me.Label12.TabIndex = 9
        Me.Label12.Text = "Reinforcement"
        '
        'numReinforcementRange
        '
        Me.numReinforcementRange.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numReinforcementRange.DecimalPlaces = 1
        Me.numReinforcementRange.Location = New System.Drawing.Point(109, -1)
        Me.numReinforcementRange.Maximum = New Decimal(New Integer() {250, 0, 0, 0})
        Me.numReinforcementRange.Name = "numReinforcementRange"
        Me.numReinforcementRange.Size = New System.Drawing.Size(130, 20)
        Me.numReinforcementRange.TabIndex = 5
        Me.numReinforcementRange.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Panel5
        '
        Me.Panel5.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
        Me.Panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel5.Controls.Add(Me.Label1)
        Me.Panel5.Controls.Add(Me.numSuggestedPV)
        Me.Panel5.Location = New System.Drawing.Point(3, 140)
        Me.Panel5.Name = "Panel5"
        Me.Panel5.Size = New System.Drawing.Size(240, 20)
        Me.Panel5.TabIndex = 4
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(3, 3)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(78, 16)
        Me.Label1.TabIndex = 9
        Me.Label1.Text = "Point Value"
        '
        'numSuggestedPV
        '
        Me.numSuggestedPV.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numSuggestedPV.DecimalPlaces = 2
        Me.numSuggestedPV.Location = New System.Drawing.Point(109, -1)
        Me.numSuggestedPV.Maximum = New Decimal(New Integer() {30000, 0, 0, 0})
        Me.numSuggestedPV.Name = "numSuggestedPV"
        Me.numSuggestedPV.Size = New System.Drawing.Size(130, 20)
        Me.numSuggestedPV.TabIndex = 6
        Me.numSuggestedPV.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Panel4
        '
        Me.Panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel4.Controls.Add(Me.Label2)
        Me.Panel4.Controls.Add(Me.numZOCRange)
        Me.Panel4.Location = New System.Drawing.Point(3, 121)
        Me.Panel4.Name = "Panel4"
        Me.Panel4.Size = New System.Drawing.Size(240, 20)
        Me.Panel4.TabIndex = 3
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(3, 3)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(96, 16)
        Me.Label2.TabIndex = 9
        Me.Label2.Text = "ZOC Range"
        '
        'numZOCRange
        '
        Me.numZOCRange.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numZOCRange.DecimalPlaces = 1
        Me.numZOCRange.Location = New System.Drawing.Point(109, -1)
        Me.numZOCRange.Maximum = New Decimal(New Integer() {250, 0, 0, 0})
        Me.numZOCRange.Name = "numZOCRange"
        Me.numZOCRange.Size = New System.Drawing.Size(130, 20)
        Me.numZOCRange.TabIndex = 5
        Me.numZOCRange.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Panel3
        '
        Me.Panel3.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
        Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel3.Controls.Add(Me.cboSize)
        Me.Panel3.Controls.Add(Me.Label5)
        Me.Panel3.Location = New System.Drawing.Point(3, 102)
        Me.Panel3.Name = "Panel3"
        Me.Panel3.Size = New System.Drawing.Size(240, 20)
        Me.Panel3.TabIndex = 2
        '
        'cboSize
        '
        Me.cboSize.FormattingEnabled = True
        Me.cboSize.Location = New System.Drawing.Point(109, -1)
        Me.cboSize.Name = "cboSize"
        Me.cboSize.Size = New System.Drawing.Size(130, 21)
        Me.cboSize.TabIndex = 10
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(3, 3)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(96, 16)
        Me.Label5.TabIndex = 9
        Me.Label5.Text = "Size"
        '
        'Panel2
        '
        Me.Panel2.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
        Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel2.Controls.Add(Me.numLOSRange)
        Me.Panel2.Controls.Add(Me.Label6)
        Me.Panel2.Location = New System.Drawing.Point(3, 64)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(240, 20)
        Me.Panel2.TabIndex = 1
        '
        'numLOSRange
        '
        Me.numLOSRange.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.numLOSRange.DecimalPlaces = 1
        Me.numLOSRange.Location = New System.Drawing.Point(109, -1)
        Me.numLOSRange.Maximum = New Decimal(New Integer() {32000, 0, 0, 0})
        Me.numLOSRange.Name = "numLOSRange"
        Me.numLOSRange.Size = New System.Drawing.Size(130, 20)
        Me.numLOSRange.TabIndex = 1
        Me.numLOSRange.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(3, 1)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(107, 17)
        Me.Label6.TabIndex = 9
        Me.Label6.Text = "Detection Range"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'pnlItem
        '
        Me.pnlItem.Controls.Add(Me.pnlProperty)
        Me.pnlItem.Controls.Add(Me.pnlTitleItem)
        Me.pnlItem.Location = New System.Drawing.Point(3, 38)
        Me.pnlItem.Name = "pnlItem"
        Me.pnlItem.Size = New System.Drawing.Size(240, 27)
        Me.pnlItem.TabIndex = 0
        '
        'pnlProperty
        '
        Me.pnlProperty.BackColor = System.Drawing.SystemColors.Window
        Me.pnlProperty.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlProperty.Controls.Add(Me.txtTypeName)
        Me.pnlProperty.Dock = System.Windows.Forms.DockStyle.Fill
        Me.pnlProperty.Location = New System.Drawing.Point(110, 0)
        Me.pnlProperty.Name = "pnlProperty"
        Me.pnlProperty.Size = New System.Drawing.Size(130, 27)
        Me.pnlProperty.TabIndex = 1
        '
        'txtTypeName
        '
        Me.txtTypeName.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.txtTypeName.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTypeName.Location = New System.Drawing.Point(1, 5)
        Me.txtTypeName.Name = "txtTypeName"
        Me.txtTypeName.Size = New System.Drawing.Size(125, 15)
        Me.txtTypeName.TabIndex = 0
        Me.txtTypeName.Text = "Type Name"
        Me.txtTypeName.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'pnlTitleItem
        '
        Me.pnlTitleItem.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlTitleItem.Controls.Add(Me.Label7)
        Me.pnlTitleItem.Dock = System.Windows.Forms.DockStyle.Left
        Me.pnlTitleItem.Location = New System.Drawing.Point(0, 0)
        Me.pnlTitleItem.Name = "pnlTitleItem"
        Me.pnlTitleItem.Size = New System.Drawing.Size(110, 27)
        Me.pnlTitleItem.TabIndex = 0
        '
        'Label7
        '
        Me.Label7.Dock = System.Windows.Forms.DockStyle.Fill
        Me.Label7.Location = New System.Drawing.Point(0, 0)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(108, 25)
        Me.Label7.TabIndex = 8
        Me.Label7.Text = "Type Name"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lblIcons
        '
        Me.lblIcons.Location = New System.Drawing.Point(22, 14)
        Me.lblIcons.Name = "lblIcons"
        Me.lblIcons.Size = New System.Drawing.Size(68, 16)
        Me.lblIcons.TabIndex = 15
        Me.lblIcons.Text = "Icon"
        '
        'picOwner
        '
        Me.picOwner.BackColor = System.Drawing.SystemColors.ControlLightLight
        Me.picOwner.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picOwner.Cursor = System.Windows.Forms.Cursors.Hand
        Me.picOwner.Location = New System.Drawing.Point(96, 2)
        Me.picOwner.Name = "picOwner"
        Me.picOwner.Size = New System.Drawing.Size(34, 34)
        Me.picOwner.TabIndex = 16
        Me.picOwner.TabStop = False
        '
        'txtDescription
        '
        Me.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtDescription.Location = New System.Drawing.Point(3, 271)
        Me.txtDescription.Multiline = True
        Me.txtDescription.Name = "txtDescription"
        Me.txtDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtDescription.Size = New System.Drawing.Size(240, 31)
        Me.txtDescription.TabIndex = 8
        Me.txtDescription.Text = "Lets see if we can get just two lines in here perfectly and with great hope."
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(136, 12)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(96, 16)
        Me.Label8.TabIndex = 19
        Me.Label8.Text = "[click icon to edit]"
        Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label13
        '
        Me.Label13.Location = New System.Drawing.Point(6, 256)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(96, 16)
        Me.Label13.TabIndex = 21
        Me.Label13.Text = "Description"
        '
        'lstAttributes
        '
        Me.lstAttributes.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lstAttributes.Location = New System.Drawing.Point(7, 91)
        Me.lstAttributes.Name = "lstAttributes"
        Me.lstAttributes.Size = New System.Drawing.Size(192, 54)
        Me.lstAttributes.TabIndex = 15
        '
        'btnAddAttribute
        '
        Me.btnAddAttribute.Image = CType(resources.GetObject("btnAddAttribute.Image"), System.Drawing.Image)
        Me.btnAddAttribute.Location = New System.Drawing.Point(207, 91)
        Me.btnAddAttribute.Name = "btnAddAttribute"
        Me.btnAddAttribute.Size = New System.Drawing.Size(32, 23)
        Me.btnAddAttribute.TabIndex = 18
        '
        'btnRemoveAttribute
        '
        Me.btnRemoveAttribute.Image = CType(resources.GetObject("btnRemoveAttribute.Image"), System.Drawing.Image)
        Me.btnRemoveAttribute.Location = New System.Drawing.Point(207, 113)
        Me.btnRemoveAttribute.Name = "btnRemoveAttribute"
        Me.btnRemoveAttribute.Size = New System.Drawing.Size(32, 23)
        Me.btnRemoveAttribute.TabIndex = 17
        '
        'lblAttrs
        '
        Me.lblAttrs.Location = New System.Drawing.Point(7, 77)
        Me.lblAttrs.Name = "lblAttrs"
        Me.lblAttrs.Size = New System.Drawing.Size(112, 16)
        Me.lblAttrs.TabIndex = 16
        Me.lblAttrs.Text = "Attributes"
        '
        'frmChitProperties
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(514, 432)
        Me.Controls.Add(Me.pnlCommon)
        Me.Controls.Add(Me.btnC1)
        Me.Controls.Add(Me.pnlRulesResources)
        Me.Controls.Add(Me.pnlUnitProperties)
        Me.Controls.Add(Me.pnlTokenProperties)
        Me.Controls.Add(Me.btnC2)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmChitProperties"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Ground Chit Properties"
        Me.pnlRulesResources.ResumeLayout(False)
        Me.pnlUnitProperties.ResumeLayout(False)
        Me.pnlUnitProperties.PerformLayout()
        CType(Me.numTransportCapacity, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.numTransportCost, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.numMovementSpeed, System.ComponentModel.ISupportInitialize).EndInit()
        Me.pnlTokenProperties.ResumeLayout(False)
        Me.pnlTokenProperties.PerformLayout()
        Me.pnlCommon.ResumeLayout(False)
        Me.pnlCommon.PerformLayout()
        Me.Panel8.ResumeLayout(False)
        Me.pnlIndicators.ResumeLayout(False)
        Me.Panel6.ResumeLayout(False)
        CType(Me.numReinforcementRange, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel5.ResumeLayout(False)
        CType(Me.numSuggestedPV, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel4.ResumeLayout(False)
        CType(Me.numZOCRange, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel3.ResumeLayout(False)
        Me.Panel2.ResumeLayout(False)
        CType(Me.numLOSRange, System.ComponentModel.ISupportInitialize).EndInit()
        Me.pnlItem.ResumeLayout(False)
        Me.pnlProperty.ResumeLayout(False)
        Me.pnlProperty.PerformLayout()
        Me.pnlTitleItem.ResumeLayout(False)
        CType(Me.picOwner, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub ButtonPush_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC1.Click, btnC2.Click
        Try
            If DirectCast(sender, Button).Text = "Close" Then
                Close_Click()
            ElseIf DirectCast(sender, Button).Text = "Add" Then
                Close_Click()
            ElseIf DirectCast(sender, Button).Text = "Cancel" Then
                Cancel_Click()
            Else
                Throw New InvalidOperationException
            End If
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub Close_Click() ' Handles btnClose.Click
        ' save the data! yay!

        mvarCancelled = False

        '// we'll put in a check for the icon here
        If ptrItem.Icon(cmplib01.IconImageIndex_cgd.Owner) Is Nothing Then
            MessageBox.Show("You must select and image to represent this item. Please set the item's image before continuing.", "Set Image")
            Exit Sub
        End If

        If Not SaveBaseProperties() Then
            MsgBox("There was a problem with some of the data in this chit. All properties may not have been saved.", MsgBoxStyle.Exclamation, "Data Error")
        End If

        ' update existing deployed units' ZOC, and LOS, I suppose movement speeds too...
        Dim GC As cmplib01.GroundChitType
        Dim GCKey As String

        '// if the item being changed is not an installation, then we can get out.
        If ptrItem.GroundChitClass <> cmplib01.GroundChitClass_cgd.Objective Then
            Me.Hide()
        End If

        Me.Hide()

    End Sub

    Private Sub Cancel_Click() 'Handles btnCancel.Click
        mvarCancelled = True
        Me.Hide()
    End Sub

#Region "Save Chit Properties"
    Private Function SaveBaseProperties() As Boolean
        Dim res As Boolean = True

        ' saves the ground chit base properties (this is all thats needed for objective types since the resources
        ' and rules are saved when you add or remove them.
        ptrItem.Description = txtDescription.Text.ToString
        ptrItem.TypeName = txtTypeName.Text

        ' icons
        ptrItem.Icon(cmplib01.IconImageIndex_cgd.Owner) = picOwner.Image
        'ptrItem.Icon(cmplib01.IconImageIndex_cgd.SameFaction) = picSameFaction.Image
        'ptrItem.Icon(cmplib01.IconImageIndex_cgd.Enemy) = picEnemy.Image

        '// movement rate
        'If TypeOf ptrItem Is cmplib01.UnitType Then
        '    DirectCast(ptrItem, cmplib01.UnitType).MovementRate = cboMovementRate.SelectedIndex
        'End If

        Try
            ptrItem.LOS = numLOSRange.Value
        Catch
            ptrItem.LOS = DEFAULT_LOS
            res = False
        End Try

        Try
            ptrItem.LOSPower = LOSPowerValue(cboLOSPower.Text)
        Catch
            ptrItem.LOSPower = DEFAULT_LOSPOWER
            res = False
        End Try

        ptrItem.Size = SizeValue(cboSize.Text)

        'If cboUsesZOC.Text = "No" Then
        'ptrItem.UsesZOC = False
        'Else
        'ptrItem.UsesZOC = True
        'End If

        If ptrItem.ZOCRange > 0 Then ptrItem.UsesZOC = True

        Try
            ptrItem.ZOCRange = numZOCRange.Value
        Catch ex As Exception
            MsgBox(ex.Message)
            ptrItem.ZOCRange = DEFAULT_ZOC
            res = False
        End Try

        ptrItem.Name = ptrItem.TypeName

        If TypeOf ptrItem Is cmplib01.UnitType Then
            DirectCast(ptrItem, cmplib01.UnitType).SuggestedPointValue = numSuggestedPV.Value
        End If

        ' if we are not editing an objective type, then update the unit type properties
        If mMode <> OpenMode.ObjectiveType Then
            If Not SaveUnitProperties() Then
                res = False
            End If
        End If

        Return res

    End Function

    Private Function SaveUnitProperties() As Boolean
        ' this saves both the data for units and tokens, since tokens have a rule which is assigned when the user
        ' selects a rule.
        Dim uni As cmplib01.UnitType
        Dim res As Boolean = True

        uni = ptrItem

        uni.MovementClassID = cboMovementType.SelectedIndex

        Try
            uni.MovementSpeed = numMovementSpeed.Value
        Catch
            uni.MovementSpeed = DEFAULT_MOVEMENTSPEED
            res = False
        End Try

        '// and here we have our transport crap
        uni.CanBeTransported = chkCanBeTransported.Checked
        uni.CanTransport = chkCanTransport.Checked
        uni.TransportCapacity = numTransportCapacity.Value
        uni.TransportCost = numTransportCost.Value
        uni.ReinforcementRange = numReinforcementRange.Value

        ' order, status and waypoints are all unique to an instance of a unit.
        Return res
    End Function
#End Region


    Private Sub picOwner_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picOwner.Click
        SetIcon(ptrItem.Icon(cmplib01.IconImageIndex_cgd.Owner))
        picOwner.Image = ptrItem.Icon(cmplib01.IconImageIndex_cgd.Owner)
    End Sub

    Private Sub SetIcon(ByRef ico As Bitmap)
        Dim path As String
        Dim fDiag As New OpenFileDialog()

        fDiag.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF; *.PNG"

        fDiag.ShowDialog()
        path = fDiag.FileName
        If path = "" Then Exit Sub
        Try
            ico = Bitmap.FromFile(path)
        Catch ex As Exception
            MsgBox("Could not load image. Please check to make sure you have a valid image file.", MsgBoxStyle.Critical, "Could Not Load Image")
        End Try
    End Sub

    Private Sub btnNewTokenRule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewTokenRule.Click
        'Dim tok As cmplib01.TokenType = ptrItem
        'Dim fRulePick As New frmRulePicker(ptrCGD, tok.TokenRule, "unit")

        'fRulePick.ShowDialog()

        'If Not fRulePick.CancelPressed Then
        '    txtTokenRule.Text = tok.TokenRule.ToString
        'End If
    End Sub


    Private Sub chkCanBeTransported_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCanBeTransported.CheckedChanged
        updateTransportVisibilty()
    End Sub

    Private Sub chkCanTransport_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCanTransport.CheckedChanged
        updateTransportVisibilty()
    End Sub

    Private Sub updateTransportVisibilty()
        numTransportCost.Visible = chkCanBeTransported.Checked
        lbltransportcost.Visible = chkCanBeTransported.Checked
        numTransportCapacity.Visible = chkCanTransport.Checked
        lbltransportcapacity.Visible = chkCanTransport.Checked
    End Sub

    Private Sub btnAddIndicator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddIndicator.Click
        cMenu.Show(sender, New System.Drawing.Point(0, 0))
    End Sub

    Private Sub btnRemoveIndicator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveIndicator.Click
        If lstIndicators.SelectedItem Is Nothing Then Exit Sub
        Try
            Dim indi As cmplib01.IIindciator
            indi = lstIndicators.SelectedItem
            ptrItem.Indicators.Remove(indi.IndicatorName)

            ListIndicators()

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub ListIndicators()
        Try

            If ptrItem.Indicators Is Nothing Then ptrItem.Indicators = New Hashtable

            lstIndicators.Items.Clear()
            Dim k As String
            For Each k In ptrItem.Indicators.Keys
                Dim indi As cmplib01.IIindciator = ptrItem.Indicators.Item(k)
                lstIndicators.Items.Add(indi)
            Next

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub CreateIndicatorMenu()
        Try
            Dim key As String
            For Each key In ptrCGD.Indicators.Keys
                Dim indi As cmplib01.IIindciator = ptrCGD.Indicators.Item(key)
                Dim menu As New MenuItem(indi.IndicatorName, AddressOf IndicatorClick)

                menu.Tag = indi
                cMenu.MenuItems.Add(menu)
            Next

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub IndicatorClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            '// add the indicator to the chit
            Dim indi As cmplib01.IIindciator = sender.tag

            If ptrItem.Indicators.ContainsKey(indi.IndicatorName) Then
                MessageBox.Show("An indicator with that name already exists in this chit.", "Invalid Indicator", MessageBoxButtons.OK, MessageBoxIcon.Hand)
                Exit Sub
            End If

            ptrItem.Indicators.Add(indi.IndicatorName, indi)
            ListIndicators()

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub btnAddAttribute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddAttribute.Click
        Try
            Dim att As String = InputBox("Enter attribute", "Attribute")
            If Not ptrItem.ChitAttributes.Contains(att) Then
                ptrItem.ChitAttributes.Add(att, att)
                ListAttributes()
            End If

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub btnRemoveAttribute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveAttribute.Click
        Try
            If lstAttributes.SelectedItem Is Nothing Then Exit Sub
            ptrItem.ChitAttributes.Remove(lstAttributes.SelectedItem)
            lstAttributes.Items.Remove(lstAttributes.SelectedItem)
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub
End Class
